$(document).ready(function(){
  $(document).click(function(){
    var lang_list = $('.languages-list', $('.blockLanguages'));
    if (lang_list.css('display') == 'block') {
      lang_list.animate({height: 'toggle'}, 'fast');
      if ($('#action_pannel') != undefined) {
          $('#action_pannel').fadeIn(700);
      }
    }
  });
  
  
  $('.current-language', $('.blockLanguages')).click(function(e){
    e.preventDefault();
    e.stopPropagation();
    var lang_list = $('.languages-list', $('.blockLanguages'));
    if (lang_list.css('display') == 'block') {
      if ($('#action_pannel') != undefined) {
          $('#action_pannel').fadeIn(700);
      }
    } else {
      if ($('#action_pannel') != undefined) {
          $('#action_pannel').fadeOut(700);
      }
    }
    $('.languages-list', $('.blockLanguages')).animate({height: 'toggle'}, 'fast');
  });
});

function submitLangForm(code) {
    
    document.languages.langCode.value=code;
    languages.submit();
}